package com.bjpowernode.style;

import com.bjpowernode.service.MyService;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableAsync;

/**
 * 使用Spring来实现多线程
 *
 * @author Cat老师，关注我，抖音搜索：java512
 */
@SpringBootApplication
@ComponentScan(basePackages = {"com.bjpowernode.service"})
@EnableAsync
public class Test05 {

    public static void main(String[] args) {

        ConfigurableApplicationContext context = SpringApplication.run(Test05.class);

        //<bean id="applicationTaskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">

        //ThreadPoolTaskExecutor applicationTaskExecutor = context.getBean(ThreadPoolTaskExecutor.class);

        //applicationTaskExecutor.execute.txt(() -> System.out.println("异步线程执行1......"));

        //applicationTaskExecutor.submit(() -> System.out.println("异步线程执行2......"));

        MyService myService = context.getBean(MyService.class);
        myService.test2();

        System.out.println("主线程执行结束......");
    }
}